package com.haidao.admin.common.utils;

import com.haidao.admin.component.resp.Option;
import com.opencsv.bean.CsvBindByName;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;


public class FieldUtils {

    public static List<Option> getDesc(Class clazz) {
        Map<String, Object> params = new HashMap<>();
        List<Option> optionList = new ArrayList<>();

        for (Field f : clazz.getDeclaredFields()) {
            CsvBindByName ann = f.getAnnotation(CsvBindByName.class);
            if (ann != null) {
                params.put(f.getName(), ann.column());
                Option o = new Option();
                o.setTitle(ann.column());
                o.setDataIndex(f.getName());
                optionList.add(o);
            }
        }
        return optionList;
    }

}
